load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
load("//bazel:defs.bzl", "rust_ic_bench")

package(default_visibility = [
    "//rs/http_endpoints:__subpackages__",
    "//rs/https_outcalls:__subpackages__",
    "//rs/pocket_ic_server:__subpackages__",
    "//rs/replica:__subpackages__",
])

rust_library(
    name = "nns_delegation_manager",
    srcs = glob(["src/**/*.rs"]),
    crate_name = "ic_nns_delegation_manager",
    deps = [
        # Keep sorted.
        "//rs/certification",
        "//rs/config",
        "//rs/crypto/tls_interfaces",
        "//rs/crypto/tree_hash",
        "//rs/crypto/utils/threshold_sig_der",
        "//rs/interfaces/registry",
        "//rs/monitoring/logger",
        "//rs/monitoring/metrics",
        "//rs/registry/helpers",
        "//rs/types/types",
        "@crate_index//:axum",
        "@crate_index//:futures",
        "@crate_index//:http-body-util",
        "@crate_index//:hyper",
        "@crate_index//:hyper-util",
        "@crate_index//:prometheus",
        "@crate_index//:rand",
        "@crate_index//:serde",
        "@crate_index//:serde_cbor",
        "@crate_index//:slog",
        "@crate_index//:tokio",
        "@crate_index//:tokio-rustls",
        "@crate_index//:tokio-util",
        "@crate_index//:tower",
    ],
)

rust_test(
    name = "nns_delegation_manager_test",
    crate = ":nns_delegation_manager",
    deps = [
        "//rs/certification/test-utils",
        "//rs/crypto/tls_interfaces",
        "//rs/crypto/tls_interfaces/mocks",
        "//rs/crypto/tree_hash",
        "//rs/crypto/utils/threshold_sig_der",
        "//rs/http_endpoints/nns_delegation_manager/test_utils",
        "//rs/monitoring/logger",
        "//rs/monitoring/metrics",
        "//rs/registry/fake",
        "//rs/registry/keys",
        "//rs/registry/proto_data_provider",
        "//rs/test_utilities/registry",
        "//rs/test_utilities/types",
        "@crate_index//:assert_matches",
        "@crate_index//:axum",
        "@crate_index//:axum-server",
        "@crate_index//:hyper",
        "@crate_index//:rand",
        "@crate_index//:rcgen",
        "@crate_index//:rustls",
        "@crate_index//:tokio",
    ],
)

rust_ic_bench(
    name = "nns_delegation_reader_bench",
    testonly = True,
    srcs = ["benches/nns_delegation_reader.rs"],
    deps = [
        # Keep sorted.
        ":nns_delegation_manager",
        "//rs/crypto/tree_hash",
        "//rs/http_endpoints/nns_delegation_manager/test_utils",
        "//rs/monitoring/logger",
        "//rs/test_utilities/types",
        "//rs/types/types",
        "@crate_index//:criterion",
        "@crate_index//:pprof",
        "@crate_index//:serde_cbor",
        "@crate_index//:tokio",
    ],
)
